from django.conf.urls import url
# JWT扩展,登陆视图
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token
from users import views

urlpatterns = [
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.UserNameCountView.as_view()),
    url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$', views.MobileCountView.as_view()),
    url(r'^users/$', views.UserRegister.as_view()),
    # url(r'^authorizations/$', obtain_jwt_token),  # 修改视图,合并购物车数据
    url(r'^authorizations/$', views.UserLogin.as_view()),
    url(r'^user/', views.UserCenterInfoView.as_view()),
    url(r'^email/$', views.EmailView.as_view()),  # 邮件发送
    url(r'^emails/verification/$', views.EmailAtiveView.as_view()),  # 邮箱激活
    # url(r'^addresses/$', views.AddressAddView.as_view())  # 收货地址新增
    url(r'^browse_histories/$', views.UserHistoryAdd.as_view())  # 用户历史浏览记录的添加
]

# 视图集路由
router = DefaultRouter()
router.register('addresses', views.AddressAddView, base_name='addresses')
urlpatterns += router.urls

# POST /addresses/ 新建  -> create
# PUT /addresses/<pk>/ 修改  -> update
# GET /addresses/  查询  -> list
# DELETE /addresses/<pk>/  删除 -> destroy
# PUT /addresses/<pk>/status/ 设置默认 -> status
# PUT /addresses/<pk>/title/  设置标题 -> title
